<template>
	<view class="tab-home-box">
		<view class="header-top">
            	<view class="tab-mine-box">
                  <uni-status-bar></uni-status-bar>
					<view class="mine-nav-bar">
					</view>
					<view class="mine-info">
						<view class="baseinfo">
							<view style="position: relative;">
								<image class="avatar" :src="avatarUrl" mode=""></image>
								<view class="edit-btn" @tap="editInfo">编辑</view>
							</view>
							<view class="authorization-btn" v-if="personalData.memberId !=null">已认证</view>
							<view class="authorization-btn" @tap="goAuthorization" v-if="personalData.memberId ==null">认证</view>
						</view>
						<view class="user-info">
							<view class="nickname">{{username}}</view>
							<view class="phone">{{deptName}}{{toolingLabelName}}</view>
						</view>
				
					</view>
					<view class="order-box">
						<view class="order-title">
							<text class="order">我的订单</text>
						</view>
						<view class="order-list">
							<view class="order-item" @tap="toOrder(0)" style="position: relative;">
								<img src="/static/img/dfh.png" alt="">
								<text>待收货</text>
								<view style="min-width:40rpx;min-height:40rpx;border-radius:50%;background-color: red;position: absolute;right:50rpx;top:0rpx;color: #FFFFFF;text-align: center;font-size: 24rpx;display: flex;align-items: center;justify-content: center;">{{waitFetchCountNum}}</view>
							</view>
							<view class="order-item" @tap="toOrder(1)">
								<img  src="/static/img/ywc.png" alt="">
								<text>已完成</text>
							</view>
							<view class="order-item" @tap="toOrder(2)">
								<img  src="/static/img/qb.png" alt="">
								<text>全部</text>
							</view>
						</view>
					</view>
					<view class="main-box">
						<view class="my-msg" @tap="goPersonal">
							<text>个人信息</text>
							<image src="../../static/images/icon-right.png" style="width:14rpx;height: 24rpx;"></image>
						</view>
						<view class="my-msg" @tap="goAbout">
							<text>关于</text>
							<image src="../../static/images/icon-right.png" style="width:14rpx;height: 24rpx;"></image>
						</view>
					</view>
					<view class="logout-btn" @tap="logout">退出登陆</view>
				</view>
		</view>
	
		
	
	</view>
</template>
<script>
	import uninumberbox from "@/components/gwc/index";
	export default {
		data() {
			return {
				banners:[],
				imageUrl: 'http://124.71.202.247:8080/image/',
				food:[],
				goodslist:[],
				currentIndex:0,
				tabActiveType:'',//分类当前项
				pagination: {
					page: 1,
					limit: 10
				},
				showGoodsFormat:false,
				goodsFormat:[],
				
				rSelect: [],
				guige: "",
				specSelected: {
				  number: "",
				  stock: "",
				  id: ""
				},
				
				total:'',
				personalData:{},
				avatarUrl:'',
				username:'',
				deptName:'',
				limitMoney:'',
				toolingLabelName:'',
				waitFetchCountNum:''
			}
		},
		components: {
		  uninumberbox
		},
		
		onLoad() {
			var that=this;
			console.log(that.imageUrl,'this.imageUrl>>>>>>')
			var userinfopre = uni.getStorageSync('userInfo');
			console.log(userinfopre,'userinfopre>>>>>>>>')
			that.avatarUrl=userinfopre.avatarUrl;
			const checkResult = uni.getStorageSync('checkResult');
			console.log(checkResult,'checkResult>>>>>>')
			if(checkResult != null){
				that.limitMoney=checkResult.limitMoney;
				that.toolingLabelName=checkResult.toolingLabelName;
			}
			// that.getPersonalData();
			if(!userinfopre){
				uni.redirectTo({
					url:'../login/login'
				})
			}
		},
		onShow() {
			var that = this;
			that.getPersonalData();
			that.waitFetchCount();
		},
		methods:{
             // 订单
			toOrder(status){
				uni.navigateTo({
					url:'../newOrder/order?orderType='+status
				})
			},
			getPersonalData(){
				var that=this;
				that.sendRequest({
					url :"/staff/profile",
					method : "GET",
					data : {},
					hideLoading : true,
					success:function (res) {
						console.log(res,'获取个人信息')
						that.personalData=res;
						that.username=res.name;
						that.deptName=res.deptName;
					},
				})
			},
			//待领取数量
			waitFetchCount(){
				var that = this;
				that.sendRequest({
					url :"/order/waitFetchCount",
					method : "GET",
					data : {},
					hideLoading : true,
					success:function (res) {
						console.log(res,'获取待领取数量');
						that.waitFetchCountNum=res.result;
						
					},
				})
			},
			goAbout(){
				uni.navigateTo({
					url:'../about/about'
				})
			},
			goPersonal(){
				var that=this;
				that.personalData=JSON.stringify(that.personalData)
				uni.navigateTo({
					url:'../personalInfo/personalInfo?personalData='+that.personalData
				})
			},
			editInfo(){
				var that=this;
				that.personalData=JSON.stringify(that.personalData)
				uni.navigateTo({
					url:'../personalInfo/personalInfo?personalData='+that.personalData+'&name=edit'
				})
			},
			goAuthorization(){
				uni.navigateTo({
					url:'../Authorization/Authorization'
				})
			},
			logout(){
				 uni.showModal({
					title: '确定要退出登录吗?',
					content: ' ',
					success: function(res) {
						if (res.confirm) {
							uni.clearStorageSync();
							uni.redirectTo({
								url:'../login/login'
							})
						}
					}
				});
				
				 
			}
		
		
			
		}
	}
</script>
<style>
@import "./index.css";
</style>
<style>
	.tab-home-box{
		width: 100%;
		height: 100%;
		/* background-color: #FFFFFF; */
	}
	.header-top{
		width: 100%;
		height: 629rpx;
		background: linear-gradient(130deg, #4EBFF9 0%, #266CBE 100%);
		position: relative;
		top: 0;
		/* left: 0; */
	}
	.header-image{
		width: 100%;
		height: 385rpx;
		position: absolute;
		top: 0;
		left: 0;
	}
	.header-title{
		position: absolute;
		top:108rpx;
		color:#FFFFFF;
		font-size: 36rpx;
		z-index: 1111;
		left: 50%;
		transform: translate(-50%, -50%);
		
	}
	.main-box{
		margin: 32rpx;
		color: #1A1C1C;
		height: 192rpx;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 24rpx;
		padding:32rpx 24rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		font-size: 32rpx;
		font-weight: bold;
		
	}
	.my-msg{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.logout-btn{
		margin: 32rpx;
		height: 88rpx;
		border: 2rpx solid #4EBFF9;
		opacity: 1;
		border-radius: 44rpx;
		color: #4EBFF9;
		line-height: 88rpx;
		text-align: center;
		font-size: 36rpx;
	}
	
	
	
</style>